<template>
	<view class="flex flex-column bg-white" style="height: 94vh;">
		<image class="rounded-lg bg-white" style="width: 100%;height: 400rpx;" src="/static/logo.png" mode="aspectFit">
		</image>
		<view class="text-center fs-40 font-weight-bold my-3">优质商户</view>
		<view class="rounded-lg p-2 bgeff3f8 mx-3 fs-32 boxshadow" @click="navTo('/pages/passport/entry/seller/control')">
			<view class="flex align-center justify-between">
				<text class="ft666666">商户编号</text>
				<text class="ft333333">sh123456</text>
			</view>
			<view class="flex align-center justify-between my-3">
				<text class="ft666666">注册时间</text>
				<text class="ft333333">2023-05-12</text>
			</view>
			<view class="flex align-center justify-between">
				<text class="ft666666">经营范围</text>
				<text class="ft333333">数码电子</text>
			</view>
		</view>
		<view class="flex mx-3">
			<view class="rounded border px-3 py-1 bde87722 fte87722 flex flex-column justify-center text-center mt-4 w-50"
				@click="navTo('/pages/store/createGoods')">
				<u-icon class="mx-auto " name="plus" size="40"></u-icon>
				<text class="fs-32">创建商品</text>
			</view>
			<view
				class="rounded border px-3 py-1 bde87722 fte87722 flex flex-column justify-center text-center ml-3 mt-4 w-50"
				@click="navTo('/pages/store/goodsManage')">
				<u-icon class="mx-auto " name="setting" size="40"></u-icon>
				<text class="fs-32">商品管理</text>
			</view>
		</view>
		<view class="flex mx-3">
			<view class="rounded border px-3 py-1 bde87722 fte87722 flex flex-column justify-center text-center  mt-4 w-50"
				@click="navTo('/pages/store/order?status=0')">
				<u-icon class="mx-auto " name="order" size="40"></u-icon>
				<text class="fs-32">订单管理</text>
			</view>
			<!--#ifdef MP-WEIXIN-->
			<view
				class="rounded border px-3 py-1 bde87722 fte87722 flex flex-column justify-center text-center ml-3 mt-4 w-50"
				@click="scan()">
				<u-icon class="mx-auto " name="scan" size="40"></u-icon>
				<text class="fs-32">扫码提货</text>
			</view>
			<!--#endif-->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			/**
			 * 唤醒客户端扫码
			 * 没权限去申请权限，有权限获取扫码功能
			 */
			async scan() {
				// #ifdef APP-PLUS
				this.isIos = plus.os.name == "iOS";
				// 判断是否是Ios
				if (this.isIos) {
					const iosFirstCamera = uni.getStorageSync("iosFirstCamera"); //是不是第一次开启相机
					if (iosFirstCamera !== "false") {
						uni.setStorageSync("iosFirstCamera", "false"); //设为false就代表不是第一次开启相机
						this.scanCode();
					} else {
						if (permission.judgeIosPermission("camera")) {
							this.scanCode();
						} else {
							// 没有权限提醒是否去申请权限
							this.tipsGetSettings();
						}
					}
				} else {
					/**
					 * TODO 安卓 权限已经授权了，调用api总是显示用户已永久拒绝申请。人傻了
					 * TODO 如果xdm有更好的办法请在 https://gitee.com/beijing_hongye_huicheng/lilishop/issues 提下谢谢
					 */
					this.scanCode();
				}

				// #endif

				// #ifdef MP-WEIXIN
				this.scanCode();
				// #endif
			},
			/**
			 * TODO 扫码功能后续还会后续增加
			 * 应该实现的功能目前计划有：
			 * 扫描商品跳转商品页面
			 * 扫描活动跳转活动页面
			 * 扫描二维码登录
			 * 扫描其他站信息 弹出提示，返回首页。
			 */
			scanCode() {
				uni.scanCode({
					success: function(res) {
						const sn = res.result
						uni.navigateTo({
							url: "/pages/store/scanCodeInfo?sn=" + sn
						});
					},
				});
			},
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
		}
	}
</script>

<style>

</style>